#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef pair<int,int> pii;

vector<int> ht[3];
vector<pii> ans;
int a[22];
void Move(int n,int x,int y)
{
    if(!n) return ;
    REP(i,n) ans.push_back(pii(x,y));
    ht[y].push_back(n);
    if(n==ht[x].back()) ht[x].pop_back();
    else ht[x].back()-=n;
}
void DisorderMove(int n,int x,int y)
{
    int ass;
    if(x+y==2) ass=1;
    else if(x+y==1) ass=2;
    else ass=0;
    if(n==1)
    {
        Move(ht[x].back(),x,y);
    }
    else
    {
        DisorderMove(n-1,x,ass);
        Move(ht[x].back(),x,y);
        DisorderMove(n-1,ass,y);
    }
}
void OrderMove(int n,int x,int y)
{
    int ass;
    if(x+y==2) ass=1;
    else if(x+y==1) ass=2;
    else ass=0;
    int si = ht[x].size();
    if(si==1)
    {
        int t = ht[x].back()-1;
        Move(t,x,ass);
        Move(1,x,y);
        Move(t,ass,y);
    }
    else if(ht[x][si-n]==1)
    {
      //  printf("!!");
        DisorderMove(n,x,y);
    }
    else
    {
        DisorderMove(n-1,x,y);
        DisorderMove(1,x,ass);
        DisorderMove(n-1,y,x);
        DisorderMove(1,ass,y);
        OrderMove(n-1,x,y);
    }
}
int main()
{
    int n;
    cin>>n;
    REP(i,n) cin>>a[i];
    a[n] = -1;
    int cnt = 1;
    REP(i,n)
    {
        if(a[i]!=a[i+1]) ht[0].push_back(cnt),cnt=1;
        else cnt++;
    }
    //cout<<ht[0].size()<<endl;
    OrderMove(ht[0].size(),0,2);
    cout<<ans.size()<<endl;
    REP(i,ans.size()) printf("%d %d\n",ans[i].first+1,ans[i].second+1);
	return 0;
}
